package com.yuerlive.rainbow.module.live.fragment;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.yuerlive.rainbow.R;
import com.yuerlive.rainbow.base.BaseFragment;
import com.yuerlive.rainbow.common.FragmentPagerAdapterImpl;
import com.yuerlive.rainbow.entity.LiveDetailData;
import com.yuerlive.rainbow.module.game.GameType;

import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by xiaoyi on 2017/5/23.
 */

public class FragmentLiveMain extends BaseFragment {
    @BindView(R.id.viewpager)
    ViewPager viewpager;
    FragmentPagerAdapterImpl adapter;
    private LiveDetailData liveDetail;


    @Override
    protected int getLayoutId() {
        return R.layout.fragment_live_main;
    }

    @Override
    public void initViews(View root) {
        adapter = new FragmentPagerAdapterImpl(getChildFragmentManager());
        adapter.addItem(new FragmentEmpty());
        adapter.addItem(FragmentLayer.newInstance(getArguments()));
        viewpager.setAdapter(adapter);
        viewpager.setCurrentItem(1);
    }

    public void setLiveDetail(LiveDetailData liveDetail) {
        this.liveDetail = liveDetail;
        ((FragmentLayer) adapter.getItem(1)).setLiveDetail(liveDetail);
    }

    @OnClick({R.id.ivExit})
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ivExit:
                mActivity.onBackPressed();
                break;
        }
    }

}
